<template>
  <div class="facility">
    <detailSection :title="'房屋设施'" :more-text="'查看更多设施'">
      <div class="facility-inner">
        <template v-for="(item, index) in houseFacility?.houseFacilitys" :key="index">
          <div class="item" v-if="houseFacility.facilitySort.includes(index)">
            <div class="head">
              <img :src="item.icon" alt="" style="height: 32px; width: 32px" />
              <div class="text">{{ item.groupName }}</div>
            </div>
            <div class="list">
              <template v-for="(item2, index2) in item.facilitys.slice(0, 4)" :key="index2">
                <div class="item2">
                  <i class="icon_check icon"></i>
                  <span>{{ item2.name }}</span>
                </div>
              </template>
            </div>
          </div>
        </template>
      </div>
    </detailSection>
  </div>
</template>

<script setup>
import detailSection from './detail-section.vue'
defineProps({
  houseFacility: {
    type: Object,
    default: () => {},
  },
})
</script>

<style scoped>
.facility {
  padding: 10px;
}
.facility-inner {
  .item {
    padding: 18px;
    display: flex;
    justify-content: space-between;
    .head {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      width: 75px;
      .text {
        text-wrap: nowrap;
      }
    }

    .list {
      display: grid;
      grid-template-columns: repeat(2, 2fr);
      flex: 1;
      margin: 0 10px;

      .item2 {
        display: flex;
        align-items: center;
        margin: 0px 18px;
        text-wrap: nowrap;
      }
    }
  }
}
</style>
